import http from '@/utils/axios'

/**
 * 获取广告跳转类型和状态下拉枚举
 * @returns { ResponsePromise } Axios Response
 */
export const getAdsJumpAndStateType = () => {
  return http({
    url: '/management-portal/carousel/getAllSelect',
    method: 'GET',
  })
}

/**
 * 获取广告列表
 * @returns { ResponsePromise } Axios Response
 */
export const getAdsList = (query) => {
  return http({
    url: '/management-portal/carousel/list',
    method: 'GET',
    params: query,
  })
}

/**
 * 新增广告
 * @param { Object } data
 * @returns { ResponsePromise } Axios Response
 */
export const createAds = (data) => {
  return http({
    url: '/management-portal/carousel/insert',
    method: 'POST',
    data,
  })
}

/**
 * 更新广告
 * @param { Object } data
 * @returns { ResponsePromise } Axios Response
 */
export const updateAds = (data) => {
  return http({
    url: '/management-portal/carousel/update',
    method: 'POST',
    data,
  })
}

/**
 * 更新广告启用、禁用状态
 * @param { Object } id 广告id
 * @returns { ResponsePromise } Axios Response
 */
export const switchAds = (id, enable) => {
  return http({
    url: '/management-portal/carousel/enable',
    method: 'GET',
    params: { id, enable },
  })
}

/**
 * 删除广告
 * @param { Object } id 广告id
 * @returns { ResponsePromise } Axios Response
 */
export const deleteAds = (id) => {
  return http({
    url: '/management-portal/carousel/delete',
    method: 'POST',
    params: { id },
  })
}

export const getALiYunInfo = () => {
  return http({
    url: `/management-portal/storage/getPostSignature?fileType=image&storageType=oss`,
    method: 'GET',
  })
}

export function uploadImg(host, pram) {
  return http({
    url: host,
    method: 'post',
    data: pram,
  })
}
